Skip to content

Fix lobby start crash for auto-generated deck variants#10643

Merged
tool4ever merged 3 commits intoCard-Forge:masterfrom
MostCromulent:autogen-variant-deck-fix
May 10, 2026
Merged

Fix lobby start crash for auto-generated deck variants#10643
tool4ever merged 3 commits intoCard-Forge:masterfrom
MostCromulent:autogen-variant-deck-fix

Conversation

@MostCromulent
Copy link
Copy Markdown
Contributor

Closes #10642.

Summary

GameLobby.startGame rejected null decks before the auto-generation logic could run, and RegisteredPlayer's constructor would NPE on the null deck if the rejection were bypassed. Mobile LobbyScreen.setReady and GameLobby.startGame itself had no equivalent of the desktop's bypass.

This change adds GameLobby.hasAutoGeneratedVariant() and routes all three call sites through it. In startGame, the auto-gen variant is detected before slot validation and the deck is generated before constructing RegisteredPlayer, so no null ever reaches the constructor.

Why this differs from the fix sketched in the issue

The issue's proposal passes a placeholder new Deck("auto-generated") to RegisteredPlayer to dodge the NPE. That works but hands throwaway data to a constructor that immediately copies it. The auto-gen variant lambdas in GameType already ignore their RegisteredPlayer argument, so generating the deck first and constructing the player with the real deck removes the placeholder entirely, lets a small section-by-section copy block that was reshaping autoDeck for no reason go away, and lets the desktop lobby's hardcoded vntMomirBasic && vntMoJhoSto check be replaced with the same helper — the issue's approach left that brittle parallel rule in place, where a future auto-gen variant would silently regress.


🤖 Generated with Claude Code

GameLobby.startGame rejected slots with a null deck and then crashed in
RegisteredPlayer's constructor when the deck arrived as null anyway,
even though MoJhoSto and MomirBasic generate decks themselves and
intentionally hide the deck chooser. The desktop lobby's setReady had a
hardcoded bypass that named both variants explicitly, but the mobile
lobby and the start path itself had no equivalent.

Add GameLobby.hasAutoGeneratedVariant() and route all three call sites
through it, so any future auto-generated variant is covered without
further edits. In startGame, detect the auto-gen variant before the
slot validation loop and generate the deck before constructing the
RegisteredPlayer — which removes the need for a placeholder deck and
drops the now-redundant section-by-section copy block.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
tool4EvEr added 2 commits May 10, 2026 17:07
@tool4ever tool4ever merged commit 59b4006 into Card-Forge:master May 10, 2026
2 checks passed
@MostCromulent MostCromulent deleted the autogen-variant-deck-fix branch May 10, 2026 18:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

BUG Something isn't working Netplay

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Network play: Cannot start MoJhoSto/MomirBasic game — lobby blocks on null deck for auto-generated variants

2 participants